﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Newbie;
using Interface;
using GameEnum;

namespace Client
{
    public class ClientGameLogicManager : Newbie.GameLogicManager
    {
        public ClientGameLogicManager()
        {
            InitSelf();
        }

        /// <summary>
        /// 自身初始化
        /// </summary>
        private void InitSelf()
        {
            RegisterGameLogicCreator(EGameLogicType.Login, () => { return new ClientGameLogicLogin(); });
            RegisterGameLogicCreator(EGameLogicType.PeaceMain, () => { return new ClientGameLogicPeaceMain(); });
        }

        /// <summary>
        /// 关联初始化
        /// </summary>
        public void Init()
        {
        }

        /// <summary>
        /// 进入Login
        /// </summary>
        public void EnterGameLogin()
        {
            var game = BuildGameLogic(EGameLogicType.Login);
            StartSwitchGameLogic(game);
        }

        /// <summary>
        /// 进入指定GameLogic
        /// </summary>
        /// <param name="gameLogicType">EGameLogicType</param>
        public void EnterGameLogic(int gameLogicType)
        {
            var game = BuildGameLogic(gameLogicType);
            if (game == null)
            {
                Log.Error("ClientGameLogicManager.EnterGameLogic not support EClientGameLogicType {0}", gameLogicType);
                return;
            }
            StartSwitchGameLogic(game);
        }
    }
}
